package com.qiall.game.gobang.event;

import com.qiall.game.gobang.RoomPool;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@Component
public class GobBangEventListener {

    /**
     * 结束对局消息
     *
     * @param gameEndEvent
     */
    @EventListener(classes = {GameEndEvent.class})
    public void gameEndEventListener(GameEndEvent gameEndEvent) {
        Integer roomId = gameEndEvent.getRoomId();
        // 清空棋盘
        RoomPool.Room room = RoomPool.getRoom(roomId);
        room.initBoard();
        //设置状态为对局结束
        room.setRoomStatus(RoomPool.Room.end);

    }
}
